package blank;

import java.io.File;
import java.io.Serializable;
import java.util.List;

public class JarArchive implements Serializable {
	
	/**
	 * generated serial version uid
	 */
	private static final long serialVersionUID = -6794655822138867353L;

	private Boolean isSourceArchive;
	
	private File archiveFile;

	public JarArchive(File archiveFile) {
		super();
		this.archiveFile = archiveFile;
		this.isSourceArchive = archiveFile.getName().contains("-sources");
	}

	public Boolean isSourceArchive() {
		return isSourceArchive;
	}

	public File getArchiveFile() {
		return archiveFile;
	}
	
	
	/**
	 * could be used for binary files as well
	 * 
	 * @return
	 */
	public List<JavaSource> getJavaSources() {
		return null;
	}
	
	public String getSourceCode(String fullName) {
		return null;
	}
	
	public boolean contains(JavaSource source) {
		return false;
	}
	
	public boolean contains(String fullName) {
		return false;
	}
	
	/**
     * @param javaFullName
     *            "javax.servlet.HttpServlet"
     * @return "javax/servlet/HttpServlet.java"
     */
    private String getJavaInsideJarNameFromJavaName(String javaFullName) {
        return javaFullName.replace(".", "/").concat(".java");
    }
    
    
    /**
     * @param jarResourceName
     * 		name of resource in jar
     * @param source
     * 		wheather to look up java sources or java classes
     * @return
     * 		fully classified java name
     */
    private String getJavaNameFromInsideJarName(String jarResourceName, boolean source) {
        final String suffix;
        if (source) {
            suffix = ".java";
        } else {
            suffix = ".class";
        }
        if (!jarResourceName.contains(suffix)) {
            return null;
        }
        return jarResourceName.replace(suffix, "").replace("/", ".");
    }



}
